﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using iCooker.NET.Core.Services.Interfaces;
using iCooker.NET.Core.DataTransferObjects;
using iCooker.NET.Core.Services;
using iCooker.NET.Tests.MockServices;

namespace iCooker.NET.Tests.TestOverServices
{
    /// <summary>
    /// Summary description for RecipeServiceTest
    /// </summary>
    [TestClass]
    public class RecipeServiceTest
    {
        private IRecipeService _recipeService;
        [TestInitialize]
        public void Setup()
        {
            _recipeService = new MockRecipeService();
        }

        [TestMethod]
        public void Can_call_method_from_service()
        {
            //prepare
            List<Recipe> listToTest = new List<Recipe>();

            //execute
            listToTest = _recipeService.GetAll().ToList();

            //test
            Assert.IsNotNull(listToTest.Count());


        }

        [TestMethod]
        public void Can_GetByID_from_service()
        {
            //prepare
            List<Recipe> listToTest = new List<Recipe>();

            //execute
            Recipe recipeToTest = _recipeService.GetById(1);

            //test
            Assert.AreEqual(recipeToTest.Id , 1);

        }

        [TestMethod]
        public void Can_Add_Recipe_to_Service()
        { 
            //prepare
            Recipe RecipeToAdd = new Recipe() { Id = 21, Guid = new Guid(), Created = DateTime.Now, Description = "A description", Author = "Me" };

            //execute
            _recipeService.Add(RecipeToAdd);

            //test
            Assert.IsNotNull(_recipeService.GetById(21));
        }

        [TestMethod]
        public void Can_Delete_Recipe_to_Service()
        {
            //prepare
            Recipe RecipeToDelete = _recipeService.GetById(1);
            //execute
            _recipeService.Delete(RecipeToDelete);

            //test
            Assert.IsNull(_recipeService.GetById(RecipeToDelete.Id));
        }
    }
}
